#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> s;
		int carry = 0;
		int n = s.size();
		int pos = n;
		for (int i = n - 1; i >= 0; i--) {
			if (carry + s[i] >= '5') {
				carry = 1;
				pos = i;
			}
			else {
				s[i] += carry;
				carry = 0;
			}
		}
		for (int i = pos; i < n; i++)s[i] = '0';
		if (carry)s = "1" + s;
		cout << s << endl;
	}
	return 0;
}